﻿<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>JBuss - 登录</title>

    <link rel="shortcut icon" href="favicon.ico">
	<link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>
	<style>
		#logo-div{
			width:100%;
		}
		h1.logo-name{
			width:600px;
			margin:0 auto;
            text-align: center;
		}
	</style>
</head>

<body class="gray-bg">

		<div>

			<h1 class="logo-name">JBuss</h1>

		</div>
    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <h3>欢迎使用 JBuss</h3>

            <form class="m-t" id="argForm" role="form">
                <div class="form-group">
                    <input type="text" name="mailOrUsername" class="form-control" autocomplete="off" value="" placeholder="账号或邮箱"/>
                </div>
                <div class="form-group">
                    <input type="password" name="pwd" class="form-control" autocomplete="off" value="" placeholder="密码" />
                </div>
                <div class="form-group" style="display: flex;">
                    <img class="imageCode" width="150px" height="34px" src="" onclick="generateImageCode()">
                    <input type="text" name="imageCode" class="form-control" autocomplete="off" placeholder="验证码" />
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" onclick="toLogin()">登 录</button>


                <p class="text-muted text-center">
                    <!--<a href="login.html#"><small>忘记密码了？</small></a> |-->
                    <a href="register.html" target="_self">注册账号</a>
                </p>

            </form>
        </div>
    </div>
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.5"></script>
	<script src="js/plugins/toastr/toastr.min.js"></script>
    <script type="text/javascript" src="js/custom/app.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/custom/tools.js" charset="UTF-8"></script>
    <script>
	$(function(){
        generateImageCode();
        const email = getQueryString("email");
        $("form#argForm").find("input[name='mailOrUsername']").val(email);
	})


    function generateImageCode(){
        $("input[name=imageCode]").val("");
        $(".imageCode").attr("src",domain + "sysUser/generateImageCode?" + (new Date()).getTime());
    }

	//登录
	function toLogin() {
        var formData = new FormData($("form#argForm")[0]);
		var url = 'sysUser/userLogin';
        jQuery.ajax({
            url:domain + url,
            type:"post",
            data:formData2JsonStr(formData),
			crossDomain:true,
			xhrFields:{
				withCredentials:true
			},
            success:function (data) {
				if(data.status == 200){
					toastr.success("登录成功！");
					window.location.href = "/index.html";
					//console.log("document.cookie: "+ document.cookie);
				}else{
                    generateImageCode();
					top.toastr.warning(data.msg);
				}
            },
            error:function(data) {
                top.toastr.error("登录失败，请检查网络");
            }
        })
    }
	</script>
</body>

</html>
